# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-github-sergi-go-diff
pkgver=1.2.0
pkgrel=1
pkgdesc="Diff, match and patch text in Go"
arch=('any')
url="https://github.com/sergi/go-diff"
license=('Apache' 'MIT')
depends=('go')
checkdepends=('golang-github-stretchr-testify')
source=("$pkgname-$pkgver.tar.gz::https://github.com/sergi/go-diff/archive/v$pkgver.tar.gz")
sha512sums=('b59255315396c872bd7606034955a748ebec00f8a585975ee165b8ef43b5dcef7e1fe9634d0e09b06b98cf19b1b635cc7ca252e5bf5b92f94c31f46c1fba5bee')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/github.com/sergi
  cp -a "$srcdir"/go-diff-$pkgver "$srcdir"/build/src/github.com/sergi/go-diff
  cd "$srcdir"/build/src/github.com/sergi/go-diff
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/github.com/sergi
  cp -a "$srcdir"/go-diff-$pkgver "$pkgdir"/usr/share/gocode/src/github.com/sergi/go-diff

  install -Dm644 go-diff-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
